function [varL,  varR] = cfdSetLR
%--------------------------------------------------------------------------
%  Written by LiuHaHa @ NWPU, 2022 01 
%  Contact me at: liuzhikan@mail.nwpu.edu.cn
%==========================================================================
% Routine Description:
%   This function calculate the left and right flow field at the interface
%--------------------------------------------------------------------------
global slvpara  cfdFlow;

owners = cfdFlow.mesh.owners;
neighbours = cfdFlow.mesh.neighbours;
theNumberOfInteriorFaces = cfdFlow.mesh.numberOfInteriorFaces;
theNumberOfFaces = cfdFlow.mesh.numberOfFaces;
cfdBoundaries = cfdFlow.mesh.cfdBoundaryPatchesArray;
numberOfBoundaries = cfdFlow.mesh.numberOfBoundaryPatches;
phyTemp = cfdFlow.Phy;
faceRf1 = cfdFlow.mesh.faceRf1;
faceRf2 = cfdFlow.mesh.faceRf2;
if (slvpara.flx_order == 2)
    Phy_gradTemp = cfdFlow.Phy_grad;
end

varL = zeros(theNumberOfFaces,slvpara.ND+2);
varR = zeros(theNumberOfFaces,slvpara.ND+2);
if (slvpara.flx_order == 1)
    for iFace=1:theNumberOfInteriorFaces
        own = owners(iFace);
        nei = neighbours(iFace);
  
        varL(iFace,:) = phyTemp(own,:);
        varR(iFace,:) = phyTemp(nei,:);
    end
    for iBPatch=1:numberOfBoundaries
        theNumberFacesOfBoundaryPatch = cfdBoundaries{iBPatch}.numberOfBFaces ;  
        startFace = cfdBoundaries{iBPatch}.startFaceIndex;
        for iBface=startFace:startFace+theNumberFacesOfBoundaryPatch-1
             own = owners(iBface);

             varL(iBface,:) = phyTemp(own,:);
        end
    end
else
    for iFace=1:theNumberOfInteriorFaces
        own = owners(iFace);
        nei = neighbours(iFace);
        for i=1:slvpara.ND+2
            varL(iFace,i) = phyTemp(own,i) + (Phy_gradTemp(own,i,1)*faceRf1(iFace,1)+...
                Phy_gradTemp(own,i,2)*faceRf1(iFace,2));
            varR(iFace,i) = phyTemp(nei,i) + (Phy_gradTemp(nei,i,1)*faceRf2(iFace,1)+...
                Phy_gradTemp(nei,i,2)*faceRf2(iFace,2));
        end
    end
    for iBPatch=1:numberOfBoundaries
        theNumberFacesOfBoundaryPatch = cfdBoundaries{iBPatch}.numberOfBFaces ;  
        startFace = cfdBoundaries{iBPatch}.startFaceIndex;
        for iBface=startFace:startFace+theNumberFacesOfBoundaryPatch-1
             own = owners(iBface);

             varL(iBface,:) = phyTemp(own,:);
        end
    end

end













